<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/selects.css"/>
	<style>
		body {
			margin:0px;
		}
	</style>
	<script type="text/javascript">
	function realizaAccion(field,valor){
		if(field.name == 'btnMostrarDatos'){
			document.forms[0].action='Licencia.do?operacion=obtenersoli';
			document.forms[0].target='';
			document.forms[0].submit();
		}else
		if(field.name == 'btnImprimirLic'){
			document.forms[0].action='Licencia.do?operacion=obtenerlic&codSoli='+valor+'&visimp=si';
			document.forms[0].target='_blank';
			document.forms[0].submit();
		}else
		if(field.name == 'btnImprimirCar'){
			document.forms[0].action='Licencia.do?operacion=obtenercarta&codSoli='+valor+'&visimp=si';
			document.forms[0].target='_blank';
			document.forms[0].submit();
		}else
		if(field.name == 'btnRegEntre'){
			document.forms[0].action='Licencia.do?operacion=regentrelic&codSoli='+valor;
			document.forms[0].target='';
			document.forms[0].submit();
		}
	}
	function validaBotones(estAp,estEntr,msj){
		if(msj != 'null' && msj != ''){
			document.forms[0].btnRegEntre.disabled = true;
			document.forms[0].btnImprimirLic.disabled = false;
			alert(msj);
		}else{
			if(estAp != 'null' && estEntr != 'null'){
				if(estAp == 'APROBADO'){
					if(estEntr == "NO ENTREGADO"){
						document.forms[0].btnRegEntre.disabled = false;
						alert('La solicitud seleccionada esta aprobada, proceda a registrar la entrega');
					}
					if(estEntr == "ENTREGADO"){
						document.forms[0].btnRegEntre.disabled = true;
						document.forms[0].btnImprimirLic.disabled = false;
						alert('Entrega de solicitud ya registrada, solo podra a imprimir');
					}
				}
				if(estAp == 'DESAPROBADO'){
					document.forms[0].btnRegEntre.disabled = true;
					document.forms[0].btnImprimirCar.disabled = false;
					alert('La solicitud seleccionada esta desaprobada, proceda a imprimir la carta de desaprobacion');
				}
			}
		}
	}
	</script>
</head>
<c:set var="solis" scope="page" value="${sessionScope.b_solicitud}"/>
<body onload="validaBotones('${solis.strEstAprobJefeLic}','${solis.strEstEntregaLic}','${requestScope.mensaje}')">
<form name="formReg" action="Licencia.do" method="post">
<table border="2" cellpadding="8">
<tr bgcolor="#FF6600">
      <td colspan="3" class="HeaderColor">
       
        <h2><fmt:message key="cu061.titReg" /></h2>
        
      </td>
    </tr>
    <tr >
      <td bgcolor="#DDDDDD" width="12%" nowrap class="LabelColor" style="text-align: right">
        <label for="solicitud"> <fmt:message key="cu061.tiSol" /> </label>
      </td>
      <td align="left" bgcolor="#DDDDDD" width="50%" class="TitleColor">
        <select name="solaprdesa">
        <c:if test="${sessionScope.l_solicapde != null}">
        <c:forEach var="soliapde" items="${sessionScope.l_solicapde}">
        	<option value="${soliapde.strCodSol}">${soliapde.strCodSol}</option>
        </c:forEach>
        </c:if>
        </select>
      </td>
	  <td align="left" bgcolor="#DDDDDD" width="50%" valign="top">
	  	<input type="button" name="btnMostrarDatos" value=<fmt:message key="cu061.mosDa" /> onclick="realizaAccion(this,'');">
	  </td>

    </tr>
<tr bgcolor="#DDDDDD" style="vertical-align: top">
 		<td colspan="3">
		<table width="700" border="3" id="tbLiq">
  <tr bgcolor="00D0E8">
  	<th scope="col"><div align="center"><em><strong><fmt:message key="cu061.codSol" /> </strong></em></div></th>
    <th scope="col"><div align="center"><em><strong><fmt:message key="cu061.nomCont" /> </strong></em></div></th>
    <th scope="col"><div align="center"><em><strong><fmt:message key="cu061.fecPago" /> </strong></em></div></th>
    <th scope="col"><div align="center"><em><strong><fmt:message key="cu061.fecReg" /> </strong></em></div></th>
    <th scope="col"><div align="center"><em><strong><fmt:message key="cu061.tecAs" /> </strong></em></div></th>
     <th scope="col"><div align="center"><em><strong><fmt:message key="cu061.visPr" /> </strong></em></div></th>
  </tr>
  <c:if test="${sessionScope.b_solicitud != null}">
  <c:set var="solcomp" value="${sessionScope.b_solicitud}"/>
  	<tr>
    	<td align="center">${solcomp.strCodSoli}</td>
    	<td align="center">${solcomp.strNombreContri} ${solcomp.strApePaterContri} ${solcomp.strApeMaterContri}</td>
    	<td align="center">${solcomp.dtFechaPago}</td>
    	<td align="center">${solcomp.dtFechaCreacion}</td>
    	<td align="center">${solcomp.strNombreUsu} ${solcomp.strApePaterUsu} ${solcomp.strApeMaterUsu}</td>
    	<c:if test="${solcomp.strEstAprobJefeLic == 'APROBADO'}">
    		<td align="center">
    			<a href="Licencia.do?operacion=obtenerlic&codSoli=${solcomp.strCodSoli}&visimp=no" target="_blank"><fmt:message key="cu061.verLic" /></a> 
    		</td>
    	</c:if>
    	<c:if test="${solcomp.strEstAprobJefeLic == 'DESAPROBADO'}">
    		<td align="center">
    			<a href="Licencia.do?operacion=obtenercarta&codSoli=${solcomp.strCodSoli}&visimp=no" target="_blank"><fmt:message key="cu061.verCar" /></a> 
    		</td>
    	</c:if>
  </tr>
  </c:if>
</table>
		</td>
    </tr>
    <tr style="vertical-align: top" bgcolor="#DDDDDD">
    	<td colspan="3">
    		<input type="button" disabled="disabled" name="btnRegEntre" value=<fmt:message key="cu061.regEntr" /> onclick="realizaAccion(this,'${solis.strCodSoli}');">
    		<c:if test="${solis.strEstAprobJefeLic == 'APROBADO'}">
    		<input type="button" disabled="disabled" name="btnImprimirLic" value=<fmt:message key="cu061.imp" /> onclick="realizaAccion(this,'${solis.strCodSoli}');">
    		</c:if>
    		<c:if test="${solis.strEstAprobJefeLic == 'DESAPROBADO'}">
    		<input type="button" disabled="disabled" name="btnImprimirCar" value=<fmt:message key="cu061.imp" /> onclick="realizaAccion(this,'${solis.strCodSoli}');">
    		</c:if>
    	</td>
    </tr>
</table>
</form>
</body>
</html>
